package com.example.simplerpc.common.serializer;

import org.I0Itec.zkclient.exception.ZkMarshallingError;
import org.I0Itec.zkclient.serialize.ZkSerializer;

import java.nio.charset.StandardCharsets;

/**
 * @Classname: ZookeeperSerializer
 * @Description: Zookeeper序列化和反序列化
 * @Author: Stonffe
 * @Date: 2022/12/18 16:12
 */
public class ZookeeperSerializer implements ZkSerializer {

    @Override
    public byte[] serialize(Object o) throws ZkMarshallingError {
        return String.valueOf(o).getBytes(StandardCharsets.UTF_8);
    }

    @Override
    public Object deserialize(byte[] bytes) throws ZkMarshallingError {
        return new String(bytes,StandardCharsets.UTF_8);
    }
}
